package cn.middle.remote.message;

import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;

import cn.middle.remote.util.ConversionUtil;

public class EdgeSignal extends BaseSignal{
	
	private byte[] data;

	public EdgeSignal() {
		super(SignalHelper.EDGE);
	}

	public void setData(byte[] data) {
		this.data = data;
	}

	public byte[] getData() {
		return data;
	}

	@Override
	public byte[] toData() {
		ByteArrayOutputStream bos = new ByteArrayOutputStream(); 
		DataOutputStream out = new DataOutputStream(bos);
		try {
			out.write(ConversionUtil.writeObjectBytes(data));
			out.flush();
			return bos.toByteArray();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return new byte[0];
	}

}
